package com.ruoyi.api.client.api;

import com.ruoyi.api.client.domain.dto.*;
import com.ruoyi.api.client.domain.vo.QbmsQuestionChapterDataVo;
import com.ruoyi.api.client.domain.vo.QbmsQuestionInfoVo;
import com.ruoyi.api.client.domain.vo.QbmsQuestionNoteVo;
import com.ruoyi.api.client.service.IClientQbmsService;
import com.ruoyi.common.annotation.RateLimiter;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.SaClientCheckLogin;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfoT;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zouhuu
 * @description 题库模块API
 * @date 2022/10/17 22:28:52
 */
@Api(tags = "客户端-题库模块API")
@RestController
@RequestMapping("/api/client/qbms")
@SaClientCheckLogin
public class QbmsApi {

    @Autowired
    private IClientQbmsService clientQbmsService;

    @ApiOperation("题库分类列表")
    @GetMapping("/category/list")
    public R categoryList() {
        return clientQbmsService.categoryList();
    }

    @ApiOperation("题库导航数据")
    @GetMapping("/nav/data")
    @ApiImplicitParam(name = "categoryId", value = "题库分类ID", dataType = "Long", required = true)
    public R navData(Long categoryId) {
        return clientQbmsService.navData(categoryId);
    }

    @ApiOperation("题库答题数据统计")
    @GetMapping("/category/answer/data")
    @ApiImplicitParam(name = "categoryId", value = "题库分类ID", dataType = "Long", required = true)
    public R categoryAnswerData(Long categoryId) {
        return clientQbmsService.categoryAnswerData(categoryId);
    }

    @ApiOperation("答题排名")
    @GetMapping("/answer/rank")
    public R answerRank(QbmsAnswerRankDto answerRankDto) {
        return clientQbmsService.answerRank(answerRankDto);
    }

    @ApiOperation("题库章节数据")
    @GetMapping("/chapter/data")
    @ApiImplicitParam(name = "categoryId", value = "题库分类ID", dataType = "Long", required = true)
    public R chapterData(Long categoryId) {
        return clientQbmsService.chapterData(categoryId);
    }

    @ApiOperation("题目章节数据")
    @GetMapping("/question/chapter/data")
    @ApiImplicitParam(name = "chapterId", value = "题库章节ID", dataType = "Long", required = true)
    public R<List<QbmsQuestionChapterDataVo>> questionChapterData(Long chapterId) {
        return clientQbmsService.questionChapterData(chapterId);
    }

    @ApiOperation("题目列表")
    @GetMapping("/question/list")
    @RateLimiter(count = 100, time = 60)
    public TableDataInfoT questionList(QbmsQuestionDto qbmsQuestionDto) {
        return clientQbmsService.questionList(qbmsQuestionDto);
    }

    @ApiOperation("题目详细信息")
    @GetMapping("/question/info")
    @ApiImplicitParam(name = "questionId", value = "题目ID", dataType = "Long", required = true)
    public R<QbmsQuestionInfoVo> questionInfo(Long questionId) {
        return clientQbmsService.questionInfo(questionId);
    }

    @ApiOperation("题目答案检查")
    @PostMapping("/question/answer/check")
    @RepeatSubmit
    public R questionAnswerCheck(@RequestBody QbmsQuestionAnswerDto qbmsQuestionAnswerDto) {
        return clientQbmsService.questionAnswerCheck(qbmsQuestionAnswerDto);
    }

    @ApiOperation("题目答案信息")
    @GetMapping("/question/answer/info")
    @ApiImplicitParam(name = "questionId", value = "题目ID", dataType = "Long", required = true)
    public R<QbmsQuestionInfoVo> questionAnswerInfo(Long questionId) {
        return clientQbmsService.questionAnswerInfo(questionId);
    }

    @ApiOperation("题目收藏保存")
    @GetMapping("/question/favorite")
    @ApiImplicitParam(name = "questionId", value = "题目ID", dataType = "Long", required = true)
    public R questionFavorite(Long questionId) {
        return clientQbmsService.questionFavorite(questionId);
    }

    @ApiOperation("题目收藏记录")
    @GetMapping("/question/favorite/record")
    @ApiImplicitParam(name = "questionId", value = "题目ID", dataType = "Long", required = true)
    public R questionFavoriteRecord(Long questionId) {
        return clientQbmsService.questionFavoriteRecord(questionId);
    }

    @ApiOperation("题目收藏列表")
    @GetMapping("/question/favorite/list")
    @ApiImplicitParam(name = "categoryId", value = "分类ID", dataType = "Long", required = true)
    public R questionFavoriteList(Long categoryId) {
        return clientQbmsService.questionFavoriteList(categoryId);
    }

    @ApiOperation("题目笔记保存")
    @PostMapping("/question/note/save")
    public R questionNote(@RequestBody QbmsRecordNoteDto qbmsRecordNoteDto) {
        return clientQbmsService.questionNoteSave(qbmsRecordNoteDto);
    }

    @ApiOperation("题目笔记内容")
    @GetMapping("/question/note/content")
    @ApiImplicitParam(name = "questionId", value = "题目ID", dataType = "Long", required = true)
    public R questionNoteContent(Long questionId) {
        return clientQbmsService.questionNoteContent(questionId);
    }

    @ApiOperation("题目笔记列表")
    @GetMapping("/question/note/list")
    @ApiImplicitParam(name = "categoryId", value = "分类ID", dataType = "Long", required = true)
    public R<QbmsQuestionNoteVo> questionNoteList(Long categoryId) {
        return clientQbmsService.questionNoteList(categoryId);
    }


    @ApiOperation("题目纠错保存")
    @PostMapping("/question/fix/save")
    public R questionFixSave(@RequestBody QbmsRecordFixDto qbmsRecordFixDto) {
        return clientQbmsService.questionFixSave(qbmsRecordFixDto);
    }

    @ApiOperation("题目解析保存")
    @PostMapping("/question/resolve/save")
    public R questionResolveSave(@RequestBody QbmsRecordResolveDto qbmsRecordResolveDto) {
        return clientQbmsService.questionResolveSave(qbmsRecordResolveDto);
    }

    @ApiOperation("题目答题列表")
    @GetMapping("/question/answer/list")
    @ApiImplicitParam(name = "categoryId", value = "分类ID", dataType = "Long", required = true)
    public R questionAnswerList(Long categoryId) {
        return clientQbmsService.questionAnswerList(categoryId);
    }

    @ApiOperation("题目错答列表")
    @GetMapping("/question/answer/mistake/list")
    @ApiImplicitParam(name = "categoryId", value = "分类ID", dataType = "Long", required = true)
    public R questionAnswerMistakeList(Long categoryId) {
        return clientQbmsService.questionMistakeList(categoryId);
    }

    @ApiModelProperty("题目答题重置")
    @GetMapping("/question/answer/renewal")
    @ApiImplicitParam(name = "chapterId", value = "章节ID", dataType = "Long", required = true)
    public R questionAnswerRenewal(Long chapterId) {
        return clientQbmsService.questionAnswerRenewal(chapterId);
    }
}
